﻿namespace KinonekoSoftware.Studio
{
    partial class Platform
    {
        
        
        public static KeywordCatalogRoot GetKeywordCatalogRoot(IRepository repo)
        {
            var keywordRoot = repo.GetOrCreate<KeywordCatalogRoot>(KeywordCatalogRoot.Create, false);
            
            if (Keywords is null)
            {
                Keywords = new HashSet<string>();
                Keywords.AddMany(keywordRoot.KeywordLists.Select(x => x.Name), true);
            }
            else if (Keywords.Count > 0)
            {
                Keywords.Clear();
                Keywords.AddMany(keywordRoot.KeywordLists.Select(x => x.Name), true);
            }
            
            //
            //
            return keywordRoot;
        }
    }
}